package com.qlslylq.ad.sdk.util;

import android.util.Log;
import android.view.View;
import android.view.ViewGroup;

/**
 * 控工具类<br/>
 */
public class ViewUtils {

    /**
     * 输出所有子控件<br/>
     */
    public static void outputAllView(ViewGroup rootGroup) {
        for (int index = 0; index < rootGroup.getChildCount(); index++) {
            View view = rootGroup.getChildAt(index);
            Log.e("view", "index：" + index + "\nview：" + view + "\ntag： "
                    + view.getTag());
            if (view instanceof ViewGroup) {
                outputAllView((ViewGroup) view);
            }
        }
    }

    /**
     * 开启(禁用)所有子控件<br/>
     */
    public static void setChildViewEnabled(ViewGroup rootGroup, boolean enabled) {
        for (int index = 0; index < rootGroup.getChildCount(); index++) {
            View view = rootGroup.getChildAt(index);
            view.setEnabled(enabled);
            if (view instanceof ViewGroup) {
                setChildViewEnabled((ViewGroup) view, enabled);
            }
        }
    }
}
